package com.hospital.util;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;

import com.hospital.registermanagement.entity.Pharmacy;
import com.hospital.warehouse.drugdicts.entity.Drugdicts;
import com.hospital.warehouse.drugdicts.service.DrugdictsService;
import com.hospital.warehouse.instock.entity.Instock;
import com.hospital.warehouse.instock.service.InstockService;
import com.hospital.warehouse.myenum.Reason;
import com.hospital.warehouse.myenum.Source;
import com.hospital.warehouse.storehouse.entity.Storehouse;
import com.hospital.warehouse.storehouse.service.StorehouseService;
import com.hospital.warehouse.sys_user.entity.Sys_user;
import com.hospital.warehouse.sys_user.service.Sys_userService;

@Component
public class AddDate {

	@Autowired
	DrugdictsService drugdictsService;
	@Autowired
	Sys_userService sys_userService;
	@Autowired
	InstockService instockService;
	@Autowired
	StorehouseService storehouseService;

	/**
	 * 添加数据集合，用于搜索选择<br>
	 * 药品、用户、入库单、库房、药房
	 * 
	 * @param model
	 */
	public void addDatas1(Model model) {
		// 添加药品集合
		List<Drugdicts> drugs = drugdictsService.list();
		model.addAttribute("drugs", drugs);

		// 添加用户集合
		List<Sys_user> users = sys_userService.list();
		model.addAttribute("users", users);

		// 添加入库单集合
		List<Instock> instocks = instockService.list();
		model.addAttribute("instocks", instocks);

		// 添加库房集合
		List<Storehouse> storehouses = storehouseService.list();
		model.addAttribute("storehouses", storehouses);

		// 添加药房集合
		List<Pharmacy> pharmacies = new ArrayList<Pharmacy>();
		Pharmacy e = new Pharmacy();
		e.setPharmacy_id(1);
		pharmacies.add(e);
		Pharmacy e2 = new Pharmacy();
		e2.setPharmacy_id(2);
		pharmacies.add(e2);
		model.addAttribute("pharmacies", pharmacies);
	}

	/**
	 * 添加数据集合，用于搜索选择<br>
	 * 来源、原因
	 * 
	 * @param model
	 */
	public void addDatas2(Model model) {
		// 添加来源
		List<Source> sources = new ArrayList<Source>();
		sources.add(Source.来自库房);
		sources.add(Source.来自药房);
		sources.add(Source.其它);
		model.addAttribute("sources", sources);
		// 添加原因
		List<Reason> reasons = new ArrayList<Reason>();
		reasons.add(Reason.过期);
		reasons.add(Reason.自然损坏);
		reasons.add(Reason.人为损坏);
		reasons.add(Reason.质量问题);
		reasons.add(Reason.长期未使用);
		reasons.add(Reason.其它);
		model.addAttribute("reasons", reasons);
	}
}
